<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd" >
<sqlMap namespace="com.uc.training.smadmin.demo.dao.DemoDao">

    <!-- 查询所有列表 -->
    <select id="getList" resultClass="com.uc.training.smadmin.demo.model.Demo">
        SELECT
          d.id AS	id,
          d.name AS name,
          d.sex AS	sex,
          d.remark AS	remark,
          d.create_time AS	createTime,
          d.update_time AS	updateTime
        FROM
          demo d
	</select>

    <!-- 查询分页列表 -->
    <select id="getDemoList" parameterClass="com.uc.training.smadmin.demo.vo.DemoListVO" resultClass="com.uc.training.smadmin.demo.re.DemoRE">
        SELECT
          d.id AS	id,
          d.name AS name,
          d.sex AS sex,
          d.remark AS	remark
        FROM
          demo d
        <dynamic prepend="where">
          <isNotEmpty property="name" prepend="and">
            d.name = #name#
          </isNotEmpty>
        </dynamic>
        <isNotNull property="offset">
            limit #offset#, #pageSize#
        </isNotNull>
	</select>

    <!-- 查询分页列表总记录数 -->
    <select id="getDemoListCount" resultClass="java.lang.Long" parameterClass="com.uc.training.smadmin.demo.vo.DemoListVO">
        SELECT
            count(1)
        FROM
            demo d
        <dynamic prepend="where">
            <isNotEmpty property="name" prepend="and">
                d.name = #name#
            </isNotEmpty>
        </dynamic>
    </select>
</sqlMap>
